# json转换
import json

data = [{"name": "王勇", "age": 18}, {"name": "李白", "age": 20}]
# 列表,内部是字典转化转换成json,
data = json.dumps(data,ensure_ascii=False)
print(data)
# 字典转换成json
data={"name":"王勇","age":18}

data = json.dumps(data,ensure_ascii=False)
print(data)
#json 转换为字典
data='[{"name": "王勇", "age": 18}, {"name": "李白", "age": 20}]'
data=json.loads(data)
print(type(data))
print(data)
data='{"name": "王勇", "age": 18}'
data=json.loads(data)
print(type(data))
print(data)

